﻿@{
    ViewBag.Title = "修改密码";
    var user = ViewBag.User as CubicFWNet.Common.OperatorModel;
}

<section class="content-header">
    <h1>
        修改密码
    </h1>
    <ol class="breadcrumb">
        <li><a href="javascript:void(0);"><i class="fa fa-dashboard"></i>@Resources.Global.PageTitle</a></li>
        <li><a href="@Url.Action("Index","Home")">首页</a></li>
        <li class="active">修改密码</li>
    </ol>
</section>

<section class="content">
    <form class="form-horizontal" method="post" id="formMain">
        <div class="box box-solid">
            <div class="box-body">
                <div class="row">
                    <div class="form-group col-md-6 col-sm-12">
                        <label for="UserName" class="col-sm-3 control-label">用户名</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="UserName" name="UserName" value="@user.UserName" readonly>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="form-group col-md-6 col-sm-12">
                        <label for="Old" class="col-sm-3 control-label">旧密码</label>
                        <div class="col-sm-9">
                            <input type="password" class="form-control" id="Old" name="Old" maxlength="20">
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="form-group col-md-6 col-sm-12">
                        <label for="New1" class="col-sm-3 control-label">新密码</label>
                        <div class="col-sm-9">
                            <input type="password" class="form-control" id="New1" name="New1" maxlength="20">
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="form-group col-md-6 col-sm-12">
                        <label for="New2" class="col-sm-3 control-label">确认新密码</label>
                        <div class="col-sm-9">
                            <input type="password" class="form-control" id="New2" name="New2" maxlength="20">
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="form-group col-md-6 col-sm-12">
                        <label class="col-sm-3 control-label"></label>
                        <div class="col-sm-9">
                            <span class="btn btn-primary " onclick="FormSub()" id="btnOk">确 定</span>&nbsp;&nbsp;&nbsp;&nbsp;
                            <span class="text-red">@ViewBag.Info</span>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </form>
</section>

@section Scripts {
<script src="~/Scripts/md5/jquery.md5.js"></script>
    <script>
        //提交表单
        function FormSub() {
            var old = $("#Old").val().trim();
            if (old.length < 6) {
                $.modalAlert("请输入6-20位旧密码！", "warning");
                return false;
            }

            var new1 = $("#New1").val().trim();
            var new2 = $("#New2").val().trim();
            if (new1.length < 6) {
                $.modalAlert("请输入6-20位新密码！", "warning");
                return false;
            }

            if (new1 != new2) {
                $.modalAlert("两次密码输入不一致！", "warning");
                return false;
            }

            $("#Old").val($.md5($.trim(old)));
            $("#New1").val($.md5($.trim(new1)));
           

            $("#btnOk").attr('disabled', "true")
            $("#formMain").submit();

        }
    </script>
}